<template>
  <basic-container>
    <avue-crud :option="option"
               :table-loading="loading"
               :data="data"
               :page="page"
               :permission="permissionList"
               :before-open="beforeOpen"
               v-model="form"
               ref="crud"
               @row-update="rowUpdate"
               @row-save="rowSave"
               @row-del="rowDel"
               @search-change="searchChange"
               @search-reset="searchReset"
               @selection-change="selectionChange"
               @current-change="currentChange"
               @size-change="sizeChange"
               @refresh-change="refreshChange"
               @on-load="onLoad"
               @cell-click="handleCell"
               :cell-class-name="addClass"
               :upload-preview="uploadPreview" 
               :upload-error="uploadError" 
               :upload-exceed="uploadExceed" 
               :upload-delete="uploadDelete" 
               :upload-before="uploadBefore" 
               :upload-after="uploadAfter">
      <template slot="menuLeft">
        <el-button type="danger"
                   size="small"
                   icon="el-icon-delete"
                   plain
                   v-if="permission.disputeProcess_delete"
                   @click="handleDelete">删 除
        </el-button>
      </template>
       <template slot-scope="scope" slot="menu">
        <el-button type="text"
                   size="small"
                   v-if="permission.work_todo_follow"
                   plain
                   class="none-border"
                   @click.stop="handleImage(scope.row,scope.index)">流程图
        </el-button>
      </template>
    </avue-crud>
    <el-dialog title="流程图"
               append-to-body
               :visible.sync="flowBox"
               :fullscreen="true">
      <iframe
        :src=flowUrl
        width="100%"
        height="700"
        title="流程图"
        frameBorder="no"
        border="0"
        marginWidth="0"
        marginHeight="0"
        scrolling="no"
        allowTransparency="yes">
      </iframe>
      <span slot="footer"
            class="dialog-footer">
        <el-button @click="flowBox = false">关 闭</el-button>
      </span>
    </el-dialog>
      <!-- 办理 -->
    <el-dialog title="办理详情"
               append-to-body
               :visible.sync="dealBox"
               width="100%" >
               <el-container>
                <el-main style="overflow: hidden;" >
                    <avue-form :option="viewOption" :rules="rules" v-model="viewForm" :upload-preview="uploadPreview" 
               :upload-before="uploadBefore" 
               :upload-after="uploadAfter">
                    </avue-form>
                </el-main>
                <el-aside width="35%"  >
                  <el-card >
                    
                       <div class="calendar-info">
                        <el-card shadow="hover">
                            <div slot="header">
                              <span>流程信息</span>
                            </div>
                            <el-row type="flex" class="row-bg">
                              <el-timeline>
                               
                                <el-timeline-item :key="flow.id" :timestamp="flow.assigneeName" v-for="flow in flowList" placement="top">
                                  <el-card shadow="hover">
                                    <p>在 [{{flow.handlingTime}}] 开始处理 [{{flow.historyActivityName}}] 环节</p>
                                    <p v-if="flow.comment!==''">批复意见: [{{flow.comment}}]</p>
                                  </el-card>
                                </el-timeline-item>
                              </el-timeline>
                            </el-row>
                          </el-card>
                          <el-card shadow="hover">
                            <div slot="header">
                              <span>流程跟踪</span>
                            </div>

                            <el-row type="flex" class="row-bg" v-if="src!=''">
                              <img :src="src" alt="design" width="100%">
                            </el-row>
                            <div slot="header" v-if="src==''">
                              <br/>
                              自办矛盾，无流程图
                            </div>
                          </el-card>
                       </div>
                    </el-card>
                </el-aside>
                 
                </el-container>
    </el-dialog>
    <el-dialog title="选择坐标点"
      ref="gridDialog"
        append-to-body
        :visible.sync="mapBox"
        :fullscreen="false"
        style="width:100%;height:900px;">
      <coordinate-map style="height:600px;" v-on:getGridData="getGridMap($event)" :lngv="form.lng ? form.lng :''" :latv="form.lat ? form.lat :''" />
    </el-dialog>
  </basic-container>
</template>

<script>
  import {getList, getDetail, add, update, remove,disputeFlowList,getIdWork} from "@/api/ninebasic/dispute/disputeProcess";
  import {getMultilevelMore} from "@/api/system/multilevelDict";
  import {mapGetters} from "vuex";
  import {validatenull} from "@/util/validate";
//打点坐标组件
  import coordinateMap from '@/components/gis/coordinateMap'
  export default {
    data() {
      return {
         mapBox: false,
        form: {
          "eventCategory": ["01", "0101"],
          "flowId": ""
        },
        viewForm:{

        },
        query: {},
        loading: true,
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0
        },
        flowBox: false,
        dealBox: false,
        flowUrl: '',
        src: '',
        selectionList: [],
        option: {
          height: 'auto',
          calcHeight: 30,
          dialogWidth: 1150,
          tip: false,
          searchShow: true,
          searchMenuSpan: 6,
          border: true,
          index: true,
          viewBtn: false,
          selection: true,
          excelBtn: false,
          dialogClickModal: false,
          column: [
            {
              label: "所属网格",
              prop: "gridId",
              type: "tree",
              span: 24,
              parent: false,
              display: true,
              dicMethod: "get",
              dicUrl: "/api/smart-system/dept/treeByPid",
              props: {
                label: "title"
              
              },
              checkStrictly: true,
              search: true,
              rules: [{
                required: true,
                message: "请输入所属网格",
                trigger: "click"
              }],
            },
            {
              label: "事件名称",
              prop: "eventName",
              type: "input",
              search: true,
              overHidden: true,
              rules: [{
                required: true,
                message: "请输入事件名称",
                trigger: "blur"
              }],
            },
            // {
            //   label: "事件编号",
            //   prop: "eventNo",
            //   type: "input",
            //   hide: true,
            // },
            {
              label: "发生日期",
              prop: "happenDate",
              type: "date",
              format: "yyyy-MM-dd",
              valueFormat: "yyyy-MM-dd",
              rules: [{
                required: true,
                message: "请输入发生日期",
                trigger: "blur"
              }],
            },
            {
              label: "发生地点",
              prop: "happenPlace",
              type: "input",
              rules: [{
                required: true,
                message: "请输入发生地点",
                trigger: "blur"
              }],
            },
            {
              label: "事件规模",
              prop: "eventScale",
              type: "select",
              dicUrl: "/api/smart-system/dict/dictionary?code=event_scale",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              search: true,
              rules: [{
                required: true,
                message: "请输入事件规模",
                trigger: "blur"
              }],
            },
            {
            label: '事件类别',
            prop: 'eventCategory',
            type: "cascader",
            dicData: [],
            filterable: true,
            hide: true,
            rules: [{
              required: true,
              message: "请输入事件类别",
              trigger: "blur"
            }],
            },
            {
              label: "涉及人数",
              prop: "numberInvolved",
              type: "input",
              hide: true,
              rules: [{
                required: true,
                message: "请输入涉及人数",
                trigger: "blur"
              }],
            },
            {
              label: "事件简述",
              prop: "eventDescription",
              type: "textarea",
              minRows:4,
              maxlength: 4000,
              showWordLimit: true,
              hide: true,
              span: 24,
              rules: [{
                required: true,
                message: "请输入事件简述",
                trigger: "blur"
              }],
            },
            {
              label: "涉及单位",
              prop: "relatedUnits",
              type: "input",
              hide: true,
            },
             {
              label: "主要当事人姓名",
              prop: "name",
              type: "input",
              search: true,
              rules: [{
                required: true,
                message: "请输入主要当事人姓名",
                trigger: "blur"
              }],
            },
            {
              label: "当事人证件",
              prop: "identificationCode",
              type: "select",
              dicUrl: "/api/smart-system/dict/dictionary?code=certificate_code",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              hide: true,
              rules: [{
                required: true,
                message: "请输入当事人证件",
                trigger: "blur"
              }],
            },
            {
              label: "当事人证件号码",
              prop: "idCard",
              type: "input",
              hide: true,
              rules: [{
                required: true,
                message: "请输入当事人证件号码",
                trigger: "blur"
              }],
            },
           
            {
              label: "当事人性别",
              prop: "sex",
              type: "select",
              dicUrl: "/api/smart-system/dict/dictionary?code=sex",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              hide: true,
              rules: [{
                required: true,
                message: "请输入当事人性别",
                trigger: "blur"
              }],
            },
            {
              label: "当事人民族",
              prop: "nation",
              type: "select",
              dicUrl: "/api/smart-system/dict/dictionary?code=nation",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              hide: true,
              rules: [{
                required: true,
                message: "请输入当事人民族",
                trigger: "blur"
              }],
            },
             {
              label: "当事人学历",
              prop: "education",
              type: "select",
              dicUrl: "/api/smart-system/dict/dictionary?code=education",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              hide: true,
              rules: [{
                required: true,
                message: "请输入学历",
                trigger: "blur"
              }],
            },
            {
            label: '当事人类别',
            prop: 'personnelCategory',
            type: "cascader",
            dicData: [],
            filterable: true,
            hide: true,
            rules: [{
              required: true,
              message: "请输入当事人人员类别",
              trigger: "blur"
            }],
            },
            {
              label: "当事人居住详址",
              prop: "detailAddress",
              type: "input",
              hide: true,
              span: 24,
              rules: [{
                required: true,
                message: "请输入主要人居住详址",
                trigger: "blur"
              }],
            },
            
            {
              label: "化解时限",
              prop: "resolvingTimeLimits",
              type: "input",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              hide: true,
            },
           
            {
              label: "化解组织",
              prop: "dissolveTheOrg",
              type: "input",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              hide: true,
              
            },
            {
              label: "化解责任人姓名",
              prop: "nameOfDefuser",
              type: "input",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              search: true,
            },
            {
              label: "化解责任人电话",
              prop: "contactOfDefuser",
              type: "input",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              hide: true,
            },
            {
              label: "化解是否成功",
              prop: "successfulOrNot",
              type: "input",
              checkStrictly: true,
               multiple: true,
              dicData: [{
                    label: "否",
                    value: "N"
              },{
                    label: "是",
                    value: "Y"
              }],
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
            },
           
           
            {
              label: "经度",
              prop: "lng",
              type: "input",
              hide: true,
              suffixIcon:'el-icon-map-location',
              props: {
                label: "lng",
                value: ""
              },
              // rules: [{
              //   required: false,
              //   message: "请选择坐标点",
              //   trigger: "click"
              // }],
              click:()=>{
                this.openGrid()
              }
            },
            {
              label: "纬度",
              prop: "lat",
              type: "input",
              hide: true,
              suffixIcon:'el-icon-map-location',
              props: {
                label: "lat",
                value: ""
              },
              // rules: [{
              //   required: false,
              //   message: "请选择坐标点",
              //   trigger: "click"
              // }],
              click:()=>{
                this.openGrid()
              }
            },
            {
              label: "办理方式",
              prop: "handleType",
              type: "select",
              dicData: [
              {
                label: "上报社区村",
                value: "community"
              },
              {
                label: "上报镇街",
                value: "streetCenter"
              },
              {
                label: "自办",
                value: "01"
              }
            ],
            hide: true,
            change: ({value}) => {
              
              this.handlerChangeType(value);
            },
            },
             {
              label: "化解方式",
              prop: "waysOfResolving",
              type: "cascader",
              dicData: [],
              filterable: true,
                hide: true,
                display: false,
              },
             {
              label: "化解情况",
              prop: "resolveTheSituation",
              type: "textarea",
              minRows:2,
              showWordLimit: true,
              hide: true,
              span: 24,
              display: false,
            },
            
             {
              label: "考评日期",
              prop: "appraisalDate",
              type: "date",
              format: "yyyy-MM-dd",
              valueFormat: "yyyy-MM-dd",
               display: false,
            },
            {
              label: "考评意见",
              prop: "reviewOpinions",
              type: "input",
              hide: true,
              span: 12,
              display: false,
            },
             {
              label: "处理意见",
              prop: "handlingSuggestion",
              type: "textarea",
              minRows:4,
              maxlength: 4000,
              showWordLimit: true,
              hide: true,
              span: 24,
            },
            {
              label: "催办次数",
              prop: "urgeCount",
              type: "input",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              hide: true,
            },
            {
              label: "指派单位",
              prop: "turnDept",
              type: "input",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              hide: true,
            },
            {
            label: '上传附件',
            prop: 'attachs',
            type: 'upload',
            hide:true,
            span: 24,
            //drag: true,
            propsHttp: {
              res: 'data',
              //label: 'name',
              //value: 'originalName',
              name: 'originalName',
              url: "link",
            },
            props: {
              label: 'name',
              value: 'link',

            },
            tip: '文件上传最大不超过100M',
            action: '/api/smart-resource/oss/endpoint/put-file'
          },
            {
              label: "下一步骤流程对应的id",
              prop: "nextFlowId",
              type: "input",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              hide: true,
            },
            {
              label: "备注",
              prop: "remark",
              type: "input",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              hide: true,
            },
             {
              type: "daterange",
              label: "发生日期",
              span: 8,
              format: "yyyy-MM-dd",
              valueFormat: "yyyy-MM-dd",
              prop: "timeLimitRange",
              searchRange: true,
              hide: true,
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              search: true,
            },
          ]
        },
        data: [],
        viewOption: {
          submitBtn:false,
          emptyBtn:false,
          column: [
            {
              label: "所属网格",
              prop: "gridId",
              type: "tree",
               disabled: true,
              span: 24,
              parent: false,
              display: true,
              dicMethod: "get",
              dicUrl: "/api/smart-system/dept/treeByPid",
              props: {
                label: "title"
              
              },
              checkStrictly: true,
              search: true,
              rules: [{
                required: true,
                message: "请输入所属网格",
                trigger: "click"
              }],
            },
            {
              label: "事件名称",
              prop: "eventName",
              type: "input",
               disabled: true,
              search: true,
              overHidden: true,
              rules: [{
                required: true,
                message: "请输入事件名称",
                trigger: "blur"
              }],
            },
            {
              label: "发生日期",
              prop: "happenDate",
              type: "date",
               disabled: true,
              format: "yyyy-MM-dd",
              valueFormat: "yyyy-MM-dd",
              rules: [{
                required: true,
                message: "请输入发生日期",
                trigger: "blur"
              }],
            },
            {
              label: "发生地点",
              prop: "happenPlace",
              type: "input",
               disabled: true,
              rules: [{
                required: true,
                message: "请输入发生地点",
                trigger: "blur"
              }],
            },
            {
              label: "事件规模",
              prop: "eventScale",
              type: "select",
               disabled: true,
              dicUrl: "/api/smart-system/dict/dictionary?code=event_scale",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              search: true,
              rules: [{
                required: true,
                message: "请输入事件规模",
                trigger: "blur"
              }],
            },
            {
            label: '事件类别',
            prop: 'eventCategory',
            type: "cascader",
             disabled: true,
            dicData: [],
            filterable: true,
            hide: true,
            rules: [{
              required: true,
              message: "请输入事件类别",
              trigger: "blur"
            }],
            },
            {
              label: "涉及人数",
              prop: "numberInvolved",
              type: "input",
               disabled: true,
              hide: true,
              rules: [{
                required: true,
                message: "请输入涉及人数",
                trigger: "blur"
              }],
            },
            {
              label: "事件简述",
              prop: "eventDescription",
              type: "textarea",
               disabled: true,
              minRows:4,
              maxlength: 4000,
              showWordLimit: true,
              hide: true,
              span: 24,
              rules: [{
                required: true,
                message: "请输入事件简述",
                trigger: "blur"
              }],
            },
            {
              label: "涉及单位",
              prop: "relatedUnits",
              type: "input",
               disabled: true,
              hide: true,
            },
             {
              label: "主要当事人姓名",
              prop: "name",
              type: "input",
               disabled: true,
              search: true,
              rules: [{
                required: true,
                message: "请输入主要当事人姓名",
                trigger: "blur"
              }],
            },
            {
              label: "当事人证件",
              prop: "identificationCode",
              type: "select",
               disabled: true,
              dicUrl: "/api/smart-system/dict/dictionary?code=certificate_code",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              hide: true,
              rules: [{
                required: true,
                message: "请输入当事人证件",
                trigger: "blur"
              }],
            },
            {
              label: "当事人证件号码",
              prop: "idCard",
              type: "input",
               disabled: true,
              hide: true,
              rules: [{
                required: true,
                message: "请输入当事人证件号码",
                trigger: "blur"
              }],
            },
           
            {
              label: "当事人性别",
              prop: "sex",
              type: "select",
               disabled: true,
              dicUrl: "/api/smart-system/dict/dictionary?code=sex",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              hide: true,
              rules: [{
                required: true,
                message: "请输入当事人性别",
                trigger: "blur"
              }],
            },
            {
              label: "当事人民族",
              prop: "nation",
              type: "select",
               disabled: true,
              dicUrl: "/api/smart-system/dict/dictionary?code=nation",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              hide: true,
              rules: [{
                required: true,
                message: "请输入当事人民族",
                trigger: "blur"
              }],
            },
             {
              label: "当事人学历",
              prop: "education",
              type: "select",
               disabled: true,
              dicUrl: "/api/smart-system/dict/dictionary?code=education",
              props: {
                label: "dictValue",
                value: "dictKey"
              },
              hide: true,
              rules: [{
                required: true,
                message: "请输入学历",
                trigger: "blur"
              }],
            },
            {
            label: '当事人类别',
            prop: 'personnelCategory',
            type: "cascader",
             disabled: true,
            dicData: [],
            filterable: true,
            hide: true,
            rules: [{
              required: true,
              message: "请输入当事人人员类别",
              trigger: "blur"
            }],
            },
            {
              label: "当事人居住详址",
              prop: "detailAddress",
              type: "input",
               disabled: true,
              hide: true,
              span: 24,
              rules: [{
                required: true,
                message: "请输入主要人居住详址",
                trigger: "blur"
              }],
            },
                   
            {
              label: "化解组织",
              prop: "dissolveTheOrg",
              type: "input",
               disabled: true,
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              hide: true,
              
            },
            {
              label: "化解责任人姓名",
              prop: "nameOfDefuser",
              type: "input",
               disabled: true,
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              search: true,
            },
            {
              label: "化解责任人电话",
              prop: "contactOfDefuser",
              type: "input",
               disabled: true,
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
              hide: true,
            },
            {
              label: "化解是否成功",
              prop: "successfulOrNot",
              type: "select",
               disabled: true,
              checkStrictly: true,
               multiple: true,
              dicData: [{
                    label: "否",
                    value: "N"
              },{
                    label: "是",
                    value: "Y"
              }],
              addDisplay: false,
              editDisplay: false,
              viewDisplay: false,
            },
           
           
            {
              label: "经度",
              prop: "lng",
              type: "input",
               disabled: true,
              hide: true,
            },
            {
              label: "纬度",
              prop: "lat",
              type: "input",
               disabled: true,
              hide: true,
            },
            {
            label: '附件信息',
            prop: 'attachs',
            type: 'upload',
             disabled: true,
            hide:true,
            span: 24,
            //drag: true,
            propsHttp: {
              res: 'data',
              //label: 'name',
              //value: 'originalName',
              name: 'originalName',
              url: "link",
            },
            props: {
              label: 'originalName',
              value: 'link',

            },
            tip: '文件上传最大不超过100M',
            action: '/api/smart-resource/oss/endpoint/put-file'
          },
          ]
        },
        viewData: []
      };
    },
    watch:{
 
    },
    components:{
      coordinateMap
    },
    computed: {
      ...mapGetters(["permission"]),
      permissionList() {
        return {
          addBtn: this.vaildData(this.permission.disputeProcess_add, false),
          viewBtn: this.vaildData(this.permission.disputeProcess_view, false),
          delBtn: this.vaildData(this.permission.disputeProcess_delete, false),
          editBtn: this.vaildData(this.permission.disputeProcess_edit, false)
        };
      },
      ids() {
        let ids = [];
        this.selectionList.forEach(ele => {
          ids.push(ele.id);
        });
        return ids.join(",");
      }
    },
     mounted() {
        this.initData();
        getIdWork().then(res => {
             console.log(res.data.data);
             this.workId = res.data.data;
               console.log(this.workId);
           })
    },
    methods: {
        //文件上传执行前
      uploadBefore(file, done, loading,column) {
         console.log("上传前"+column.prop+file.size);
         if(column.prop=="attachs"){
           const isLt100M = file.size / 1024 / 1024 < 100;
           if(!isLt100M){
            loading();
            return this.$message.error("上传文件大小不超过100M!")
           }
         }
        done()
      },
      //自定义查看方法
      uploadPreview(file,column,done){
        if(column.prop=="attachs"){
          window.open(`${file.url}`);
        }
        done()//默认执行打开方法
      },
       //打开地图图层
        openGrid(){
        this.mapBox = true
      },

      //地图选择组件回调处理数据
      getGridMap(data){
        console.log("callback:",data)

        if(data){
          this.form.lng = data.lng
          this.form.lat = data.lat
        }

        this.mapBox = false
      },
      handleCancel(){
        this.dealBox = false;
      },
      //
       addClass({columnIndex}){
                if(columnIndex === 3 ){
                  return 'cell-blue'
                }
            },
      //查看流程图
      handleImage(row) {
        if(!validatenull(row.flowId)){
          this.flowUrl = `/api/smart-flow/process/diagram-view?processInstanceId=${row.flowId}`;
          this.flowBox = true;
        }else{
           this.$message.error("自办矛盾，无流程图");
        }
      },
      //查看
      handleCell(row,column){
        const attachs = this.findObject(this.viewOption.column,"attachs");
        attachs.action = '/api/smart-resource/oss/endpoint/put-file-attach-by-id?flowId='+row.id;
        if(column.label=="事件名称") {

            //流程图
             if(!validatenull(row.flowId)){
              this.src = `/api/smart-flow/process/diagram-view?processInstanceId=${row.flowId}`;
             }
            //流程信息--这是用的自己的流程
            disputeFlowList(row.id).then(res=>{
            const data = res.data;
              if (data.success) {
                this.flowList = data.data;
              }
            })
            getDetail(row.id).then(res => {
              this.viewForm = res.data.data;
                if(this.viewForm.hasOwnProperty("personnelCategory")){
                  this.viewForm.personnelCategory = res.data.data.personnelCategory.split(",");
                }
                if(this.viewForm.hasOwnProperty("eventCategory")){
                  this.viewForm.eventCategory = res.data.data.eventCategory.split(",");
                }
                if(this.viewForm.hasOwnProperty("waysOfResolving")){
                  this.viewForm.waysOfResolving = res.data.data.waysOfResolving.split(",");
                }
                    this.dealBox = true;
              });
        }
      },
      handlerChangeType(value){
            var waysOfResolving = this.findObject(this.option.column ,"waysOfResolving");
            var resolveTheSituation = this.findObject(this.option.column,"resolveTheSituation");
            var appraisalDate  = this.findObject(this.option.column , "appraisalDate");
            var reviewOpinions = this.findObject(this.option.column,"reviewOpinions");
            if(value == '01') {
                waysOfResolving.display= true;
                resolveTheSituation.display = true;
                appraisalDate.display = true;
                reviewOpinions.display = true;
                let dictType = "resolve_type";
                getMultilevelMore(dictType).then(res=>{
                    var waysOfResolving =this.findObject(this.option.column,'waysOfResolving');
                    waysOfResolving.dicData = res.data.data;
                  })
            }else{
                waysOfResolving.display= false;
                resolveTheSituation.display = false;
                appraisalDate.display = false;
                reviewOpinions.display = false;
            }
      },
       initData() {
       let dictType1 = "event_type";
        getMultilevelMore(dictType1).then(res=>{
          var eventCategory =this.findObject(this.option.column,'eventCategory');
          eventCategory.dicData = res.data.data;
          var eventCategory1 =this.findObject(this.viewOption.column,'eventCategory');
          eventCategory1.dicData = res.data.data;
        });
      let dictType2 = "personnel_category";
      getMultilevelMore(dictType2).then(res=>{
          var personnelCategory =this.findObject(this.option.column,'personnelCategory');
          personnelCategory.dicData = res.data.data;
          var personnelCategory2 =this.findObject(this.viewOption.column,'personnelCategory');
          personnelCategory2.dicData = res.data.data;
        });
      },
      rowSave(row, done, loading) {
        console.log("提交="+JSON.stringify(row))
        row.personnelCategory = row.personnelCategory.join(",");
        row.eventCategory = row.eventCategory.join(",");
        row.waysOfResolving = row.waysOfResolving.join(",");
        add(row).then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          loading();
          window.console.log(error);
        });
      },
      rowUpdate(row, index, done, loading) {
        row.personnelCategory = row.personnelCategory.join(",");
        row.eventCategory = row.eventCategory.join(",");
         row.waysOfResolving = row.waysOfResolving.join(",");
        update(row).then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        }, error => {
          loading();
          window.console.log(error);
        });
      },
      rowDel(row) {
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(row.id);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
        }
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(this.ids);
          })
          .then(() => {
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
            this.$refs.crud.toggleSelection();
          });
      },
      beforeOpen(done, type) {
         if (["add"].includes(type)) {
           
          setTimeout(() => {
            //新增时添加默认值
            this.form.handleType = 'community',
            this.form.sex = '1';
            this.form.nation = '01';
            this.form.identificationCode = '01';
            this.form.id = this.workId;
            const attachs = this.findObject(this.option.column,"attachs");
            console.log("id===="+this.workId);
            attachs.action = '/api/smart-resource/oss/endpoint/put-file-attach-by-id?flowId='+this.form.id;
          }, 10);
        }
        if (["edit", "view"].includes(type)) {
          getDetail(this.form.id).then(res => {
           //this.form = res.data.data;
             if(this.form.hasOwnProperty("personnelCategory")){
              this.form.personnelCategory = res.data.data.personnelCategory.split(",");
            }
             if(this.form.hasOwnProperty("eventCategory")){
              this.form.eventCategory = res.data.data.eventCategory.split(",");
            }
              if(this.form.hasOwnProperty("waysOfResolving")){
              this.form.waysOfResolving = res.data.data.waysOfResolving.split(",");
            }
          });
        }
        done();
      },
      searchReset() {
        this.query = {};
        this.onLoad(this.page);
      },
      searchChange(params, done) {
        this.query = params;
        this.page.currentPage = 1
        this.onLoad(this.page, params);
        done();
      },
      selectionChange(list) {
        this.selectionList = list;
      },
      selectionClear() {
        this.selectionList = [];
        this.$refs.crud.toggleSelection();
      },
      currentChange(currentPage){
        this.page.currentPage = currentPage;
      },
      sizeChange(pageSize){
        this.page.pageSize = pageSize;
      },
      refreshChange() {
        this.onLoad(this.page, this.query);
      },
      onLoad(page, params = {}) {
          const {timeLimitRange} = params;
        let values = {
          ...params,
        };
        if (timeLimitRange) {
          values = {
            ...params,
            beginTime: timeLimitRange[0],
            endTime: timeLimitRange[1],
          };
          values.timeLimitRange = null;
          this.query.timeLimitRange = null;
        }
        this.loading = true;
        getList(page.currentPage, page.pageSize, Object.assign(values, this.query)).then(res => {
          const data = res.data.data;
          this.page.total = data.total;
          this.data = data.records;
          this.loading = false;
          this.selectionClear();
        });
      }
    }
  };
</script>

<style>
.el-form-item__content{
   margin-left: 130px ! important;
}
.el-form-item__label {
  width: 130px ! important;
}
.cell-blue{
      color: blue!important;
      cursor: pointer;
  }
</style>
